import gpio
import os
class Light:
    def __init__(self,pin_num):
        self.pin_num = pin_num
        self.is_on = False
        #找柱脚
        gpio.gpio_init(self.pin_num)
        #具体操作模块
        func = gpio.query_func_value(self.pin_num, 'gpio')
        gpio.set_func(pin_num, func)
        gpio.set_dir(pin_num, gpio.dir_out)
        #设置灯状态
        gpio.set_output(pin_num, 1)
    def on(self):
        gpio.set_output(self.pin_num,1)
        self.is_on = True
    def off(self):
        gpio.set_output(self.pin_num,0)
        self.is_on = False
    def change(self):
        if self.is_on :
            self.off()
        else:
            self.on()

